package com.dingding.transfer.stamper.constant;

/**
 * @author wangxiyuan
 * @description
 * @createDate 2021/3/31 19:07
 **/
public enum Code {
    UNDEFINED(-1, "未定义"),
    SUCCESS(0, "成功"),
    ERROR(1, "失败"),
    APPLY_DETAIL_MISSING(4,"申请记录找不到"),
    HAVE_PUSHED(5,"申请使用次数已经用完,请重新申请"),
    TEMPLETE_MISSING(6,"没有找到对应的模板信息，请重新定义");
    private int code;
    private String msg;

    // 构造方法
    Code(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public static String getMsgByCodeInt(int codeInt) {
        for (Code e : Code.values()) {
            if (e.getCode() == codeInt) {
                return e.msg;
            }
        }
        throw new IllegalArgumentException("未定义的code码:" + codeInt);
    }

    public static Code getCodeByCodeInt(int codeInt) {
        for (Code code : Code.values()) {
            if (code.getCode() == codeInt) {
                return code;
            }
        }
        throw new IllegalArgumentException("未定义的code码:" + codeInt);
    }
}
